
import Index from '@/pages/IndexPage.vue';
import User from '@/pages/UserPage.vue';
import SearchPage from '@/pages/SearchPage.vue';
import Team from '@/pages/TeamPage.vue';
import Login from '@/pages/LoginPage.vue';
import SearchResult from '@/pages/SearchResultPage.vue';
import Register from '@/pages/RegisterPage.vue';
import * as VueRouter from 'vue-router';
import UserUpdatePage from '@/pages/UserUpdatePage.vue';
import UserEditPage from '@/pages/UserEditPage.vue';
import ContactMe from '@/pages/ContactMe.vue';
import FriendPage from '@/pages/FriendPage.vue';
import UserIntroPage from '@/pages/UserIntroPage.vue';
import TeamAddPage from '@/pages/TeamAddPage.vue';
import ChatPage from '@/pages/ChatPage.vue';
import TeamIntroduce from '@/pages/TeamIntroduce.vue';
import MyTeamPage from '@/pages/MyTeamPage.vue';
import JoinTeamPage from '@/pages/JoinTeamPage.vue';
import UserUpdateTagsPage from '@/pages/UserUpdateTagsPage.vue';

const routes = [
    {
        path:'/',
        component:Index,
        meta:{
            title:'欢迎来到开黑平台'
        }

    },
    
    {
        path:'/user',
        component:User,
        meta:{
            title:'个人中心'
        }
    },
    {
        path:'/team',
        component:Team,
        meta:{
            title:'队伍'
        }
    },
    {
        path:'/search',
        component:SearchPage,
        meta:{
            title:'标签搜索'
        }
    },
    {
        path:'/user/ListByTag',
        component:SearchResult,
        meta:{
            title:'搜索结果'
        }
    },
    {
        path:'/user/login',
        component:Login,
        meta:{
            title:'登录'
        }
    },
    {
        path:'/user/register',
        component:Register,
        meta:{
            title:'注册'
        }
    },
    {
        path:'/user/update',
        component:UserUpdatePage,
        meta:{
            title:'更新个人信息'
        }
    },
    {
        path:'/user/edit',
        component:UserEditPage,
        meta:{
            title:'编辑个人信息'
        }
    },
    {
        path:'/contact',
        component:ContactMe,
        meta:{
            title:'联系作者'
        }
    },
    {
        path:'/friend',
        component:FriendPage,
        meta:{
            title:'好友'
        }
    },
    {
        path:'/user/intro',
        component:UserIntroPage,
        meta:{
            title:'好友信息'
        },
        beforeEnter: (to, from, next) => {
            if(from.fullPath === '/friend'){
                to.meta.flag = true
            }else {
                to.meta.flag = false
            }
            next()
        }
        
    },
    {
        path:'/chat',
        component:ChatPage,
        meta:{
            title:'聊天'
        }
    },
    {
        path:'/team/add',
        component:TeamAddPage,
        meta:{
            title:'创建队伍'
        }
    },
    {
        path:'/team/introduce',
        component:TeamIntroduce,
        meta:{
            title:'队伍介绍'
        }
    },
    {
        path:'/user/team/create',
        component:MyTeamPage,
        meta:{
            title:'我创建的队伍'
        }
    },
    {
        path:'/user/team/join',
        component:JoinTeamPage,
        meta:{
            title:'我加入的队伍'
        }
    },
    {
        path:'/user/update/tags',
        component:UserUpdateTagsPage,
        meta:{
            title:'更新用户标签'
        }
    },
]

const router = VueRouter.createRouter({
    history:VueRouter.createWebHashHistory(),
    routes,
})

export default router